{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>会员组列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-2" style="width: 100px">
                        <div class="input-group">
                            <a href="{:url('add_group')}">
                                <button class="btn btn-outline btn-primary" type="button">添加会员组</button>
                            </a>
                        </div>
                    </div>
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('group')}">
                        <div class="col-sm-3">
                            <div class="input-group">
                                <input type="text" id="key" class="form-control" name="key" value=""
                                       placeholder="输入需查询的会员组"/>
                                <span class="input-group-btn"> 
                                    <button type="submit" class="btn btn-primary" lay-submit lay-filter="search"><i
                                            class="fa fa-search"></i> 搜索</button>
                                </span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-table"
                           lay-data="{id:'group',height:'full-210',url:'group',method:'post',page:true,limit:10}"
                           lay-filter="group">
                        <thead>
                        <tr>
                            <th lay-data="{title:'ID',field:'id',width:60,align:'center',fixed:true}"></th>
                            <th lay-data="{title:'会员组名称',field:'group_name',width:150}"></th>
                            <th lay-data="{title:'状态',field:'status',templet:'#status',width:120,align:'center'}"></th>
                            <th lay-data="{title:'创建时间',field:'create_time',width:180,align:'center'}"></th>
                            <th lay-data="{title:'更新时间',field:'update_time',width:180,align:'center'}"></th>
                            <th lay-data="{title:'操作',toolbar:'#action',width:150,align:'center',fixed:'right'}"></th>
                        </tr>
                        </thead>
                    </table>
                    <script type="text/html" id="status">
                        <input type="checkbox" name="status" lay-skin="switch" lay-text="开启|关闭" value="{{d.id}}" title="关闭" lay-filter="status"
                               {{d.status==1?'checked':''}}>
                    </script>
                    <script type="text/html" id="action">
                        <div class="layui-btn-group">
                            <button onclick="edit_group({{d.id}})"
                               class="layui-btn layui-btn-xs">
                                <i class="fa fa-paste"></i> 编辑</button>&nbsp;&nbsp;
                            <button href="javascript:;" onclick="del_group({{d.id}})"
                               class="layui-btn layui-btn-danger layui-btn-xs">
                                <i class="fa fa-trash-o"></i> 删除</button>
                        </div>
                    </script>

                </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
    var form = layui.form, table = layui.table;
    $(".spiner-example").css('display', 'none'); //数据加载完关闭动画

    /**
     * search
     */
    form.on('submit(search)', function (result) {
        var data = result.field;
        table.reload('group', {
            where: {
                key: data.key
            }
        });
        return false;
    });

    //编辑会员组
    function edit_group(id) {
        location.href = './edit_group/id/' + id + '.html';
    }

    //删除会员组
    function del_group(id) {
        lunhui.confirm(id, '{:url("del_group")}');
    }

    /**
     * 监听锁定操作
     */
    form.on('switch(status)', function (obj) {
        $.post("{:url('group_status')}", {id: this.value}, function (result) {
                //layer.tips(result.msg, obj.othis, {tips: 4});
        });
    });
</script>
</body>
</html>